import { formatCurrency } from "../utils/help";

let option = {
    tooltip: {
        formatter: function (info) {
          var value = info.value;
          return [
            "持仓：" + formatCurrency(value)
          ].join('');
        }
      },
    series: [
      {
        type: 'treemap',
        data: [
          {
            name: 'nodeA',
            value: 10,
            children: [
              {
                name: 'nodeAa',
                value: 4
              },
              {
                name: 'nodeAb',
                value: 6
              }
            ]
          },
          {
            name: 'nodeB',
            value: 20,
            children: [
              {
                name: 'nodeBa',
                value: 20,
                children: [
                  {
                    name: 'nodeBa1',
                    value: 20
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  };


export function builtTreeMapEchartOption(rawData) {
    let ret = [];
    rawData.forEach(element => {
        ret.push({
            name: element.stock,
            value: element.holdMarketCap,
        });
    });
    option.series[0].data = ret;
  return option;
}